﻿using DevExpress.XtraGrid.Views.Grid;
using RecruitStudents.Client.BLL;
using RecruitStudents.Utility;
using RecruitStudents.Utility.Const;
using RecruitStudents.Utility.Helper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RecruitStudents.Client.Base
{
    public partial class Base_SpecialityKinds_List : BaseForm
    {
        ServiceBase service = new ServiceBase();
        public Base_SpecialityKinds_List()
        {
            InitializeComponent();
            BindData();
            gridView1.OptionsBehavior.Editable = false;
        }
        private void BindData()
        {
            DataTable dt = service.GetSpecialityKindsTable(txtSpecialityKindsNO.Text.ToSafeString(), txtSpecialityKindsName.Text.ToSafeString(), "", "");
                dataGridViewX1.DataSource = dt;
            
        }
        private void benQuery_Click(object sender, EventArgs e)
        {
            BindData();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            Base_SpecialityKinds_Option option = new Base_SpecialityKinds_Option(string.Empty);
            if (option.ShowDialog() == DialogResult.OK)
            {
                this.BindData();
            }
        }

        private void gridView1_DoubleClick(object sender, EventArgs e)
        {
            GridView rows = sender as GridView;
            int[] inteurm = rows.GetSelectedRows();
            if (inteurm != null && inteurm.Length > 0)
            {
                string SpecialityKindsNO = rows.Rows[inteurm[0]].DataRow.ItemArray[0].ToString();
                Base_SpecialityKinds_Option option = new Base_SpecialityKinds_Option(SpecialityKindsNO);
                if (option.ShowDialog() == DialogResult.OK)
                {
                    this.BindData();
                }
            }
        }
    }
}
